package com.zwan.oam_rtc.utils.messages;

import com.zwan.oam_rtc.utils.wintcp.ByteTransfer;

import java.nio.ByteBuffer;

public class SLPfetchdata extends AbstractStruct{

    private byte[] messageBodyHeader = new byte[8];
    private byte[] eventname = new byte[50];
    private byte[] parameters = new byte[500];
    private static int LENGTH = 8+550;

    /**
     * 返回消息写入buffer
     */
    @Override
    public void writeToBuffer(ByteBuffer bf) {
        bf.put(messageBodyHeader);
        bf.put(eventname);
        bf.put(parameters);
    }

    /**
     * buffer读出返回消息
     */
    @Override
    public void readFromBuffer(ByteBuffer bf) {
        bf.get(messageBodyHeader);
        bf.get(eventname);
        bf.get(parameters);
    }

    public String getEventname() {
        return ByteTransfer.getString(eventname);
    }

    public void setEventname(String eventname) {
        ByteTransfer.str2Byte(eventname, this.eventname);
    }

    public String getParameters() {
        return ByteTransfer.getString(parameters);
    }

    public void setParameters(String parameters) {
        ByteTransfer.str2Byte(parameters, this.parameters);
    }


    @Override
    public int getLength() {
        return LENGTH;
    }
    public byte[] getMessageBodyHeader() {
        return messageBodyHeader;
    }
}
